package com.ruoyi.ss.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ss.domain.SsParticipants;
import com.ruoyi.ss.service.ISsParticipantsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 参赛者报名Controller
 * 
 * @author ruoyi
 * @date 2025-08-04
 */
@RestController
@RequestMapping("/ss/participants")
public class SsParticipantsController extends BaseController
{
    @Autowired
    private ISsParticipantsService ssParticipantsService;

    /**
     * 查询参赛者报名列表
     */
    @PreAuthorize("@ss.hasPermi('ss:participants:list')")
    @GetMapping("/list")
    public TableDataInfo list(SsParticipants ssParticipants)
    {
        startPage();
        List<SsParticipants> list = ssParticipantsService.selectSsParticipantsList(ssParticipants);
        return getDataTable(list);
    }

    /**
     * 导出参赛者报名列表
     */
    @PreAuthorize("@ss.hasPermi('ss:participants:export')")
    @Log(title = "参赛者报名", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SsParticipants ssParticipants)
    {
        List<SsParticipants> list = ssParticipantsService.selectSsParticipantsList(ssParticipants);
        ExcelUtil<SsParticipants> util = new ExcelUtil<SsParticipants>(SsParticipants.class);
        util.exportExcel(response, list, "参赛者报名数据");
    }

    /**
     * 获取参赛者报名详细信息
     */
    @PreAuthorize("@ss.hasPermi('ss:participants:query')")
    @GetMapping(value = "/{ssParticipantsId}")
    public AjaxResult getInfo(@PathVariable("ssParticipantsId") Long ssParticipantsId)
    {
        return success(ssParticipantsService.selectSsParticipantsBySsParticipantsId(ssParticipantsId));
    }

    /**
     * 新增参赛者报名
     */
    @PreAuthorize("@ss.hasPermi('ss:participants:add')")
    @Log(title = "参赛者报名", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SsParticipants ssParticipants)
    {
        return toAjax(ssParticipantsService.insertSsParticipants(ssParticipants));
    }

    /**
     * 修改参赛者报名
     */
    @PreAuthorize("@ss.hasPermi('ss:participants:edit')")
    @Log(title = "参赛者报名", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SsParticipants ssParticipants)
    {
        return toAjax(ssParticipantsService.updateSsParticipants(ssParticipants));
    }

    /**
     * 删除参赛者报名
     */
    @PreAuthorize("@ss.hasPermi('ss:participants:remove')")
    @Log(title = "参赛者报名", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ssParticipantsIds}")
    public AjaxResult remove(@PathVariable Long[] ssParticipantsIds)
    {
        return toAjax(ssParticipantsService.deleteSsParticipantsBySsParticipantsIds(ssParticipantsIds));
    }
}
